package com.yeepay.skb.biz;


import com.yeepay.skb.util.Conts;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 代理商返佣转账接口
 */
public class TransferToCustomerPartsBuilder extends YeepayBuilder{

    protected List<Part> parts = new ArrayList<Part>(8);
    protected String url= Conts.baseRequestUrl + "/transferToCustomer.action";

    private ArrayList<String> needHmac=new ArrayList<>(Arrays.asList(
            "mainCustomerNumber",
            "customerNumber",
            "requestId",
            "transAmount",
            "remark"
    ));

    public Part[] generateParams() {
        return parts.toArray(new Part[parts.size()]);
    }

    public TransferToCustomerPartsBuilder setMainCustomerNumber(String mainCustomerNumber) {
        this.parts
                .add(new StringPart("mainCustomerNumber",
                        mainCustomerNumber == null ? "" : mainCustomerNumber,
                        "UTF-8"));
        return this;
    }

    public TransferToCustomerPartsBuilder setCustomerNumber(String customerNumber) {
        this.parts
                .add(new StringPart("customerNumber",
                        customerNumber == null ? "" : customerNumber,
                        "UTF-8"));
        return this;
    }

    public TransferToCustomerPartsBuilder setTransAmount(String transAmount) {
        this.parts
                .add(new StringPart("transAmount",
                        transAmount == null ? "" : transAmount,
                        "UTF-8"));
        return this;
    }

    public TransferToCustomerPartsBuilder setRequestId(String requestId) {
        this.parts
                .add(new StringPart("requestId",
                        requestId == null ? "" : requestId,
                        "UTF-8"));
        return this;
    }

    public TransferToCustomerPartsBuilder setRemark(String remark) {
        this.parts
                .add(new StringPart("remark",
                        remark == null ? "" : remark,
                        "UTF-8"));
        return this;
    }

    public void setHmac(String hmac) {
        this.parts
                .add(new StringPart("hmac",
                        hmac == null ? "" : hmac,
                        "UTF-8"));
    }

    @Override
    public List<String> needHmacArr() {
        return needHmac;
    }

    public List<Part> getParts() {
        return parts;
    }

    @Override
    public String getUrl() {
        return url;
    }
}
